package com.oe.ldmrabbitmq.controller;

import com.oe.ldmrabbitmq.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class OrderController {


   @Autowired
    OrderService orderService;

    /**
     * 下单接口
     * @param payAmt
     * @return 返回订单ID
     */
    @RequestMapping("/order/create/{payAmt}")
    public String createOrder(@PathVariable("payAmt")BigDecimal payAmt){
        return orderService.createOrder(payAmt);
    }


    /**
     * 支付接口
     * @param orderId  订单ID
     * @return 返回支付成功或失败
     */
    @RequestMapping("/order/pay/{orderId}")
    public String createOrder(@PathVariable("orderId")String orderId){
        return orderService.pay(orderId);
    }

    /**
     * 取消订单接口
     * @param orderId
     * @return 返回取消成功或失败
     */
    @RequestMapping("/order/cancel/{orderId}")
    public String cancelOrder(@PathVariable("orderId")String orderId){
        return orderService.cancelOrder(orderId);
    }
}
